home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume11 / starchart / part14 < prev    next >
Encoding:
Text File  |  1990-03-25  |  27.4 KB  |  1,044 lines

  1. Newsgroups: comp.sources.misc
  2. subject: v11i042: starchart 3.2 Part 14/32
  3. from: ccount@ATHENA.MIT.EDU
  4. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5.  
  6. Posting-number: Volume 11, Issue 42
  7. Submitted-by: ccount@ATHENA.MIT.EDU
  8. Archive-name: starchart/part14
  9.  
  10. [Sorry for the delay; compiler confusion after the latest uunet swap caused
  11. my programs to hang.  And I'm at the point where it's impossible for me to
  12. avoid duplicate archive names manually.  ++bsa]
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then unpack
  16. # it by saving it into a file and typing "sh file".  To overwrite existing
  17. # files, type "sh file -c".  You can also feed this as standard input via
  18. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  19. # will see the following message at the end:
  20. #        "End of archive 14 (of 32)."
  21. # Contents:  starchart/starsunv.c
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. if test -f 'starchart/starsunv.c' -a "${1}" != "-c" ; then 
  24.   echo shar: Will not clobber existing file \"'starchart/starsunv.c'\"
  25. else
  26. echo shar: Extracting \"'starchart/starsunv.c'\" \(25159 characters\)
  27. sed "s/^X//" >'starchart/starsunv.c' <<'END_OF_FILE'
  28. X/*
  29. X * Sunview driver for starchart.c 3.0 6/15/89
  30. X *
  31. X * Driver creates sunview window and draws starchart information inside.
  32. X *
  33. X *
  34. X * Copyright (c) 1990 by Craig Counterman. All rights reserved.
  35. X *
  36. X * This software may be redistributed freely, not sold.
  37. X * This copyright notice and disclaimer of warranty must remain
  38. X *    unchanged. 
  39. X *
  40. X * No representation is made about the suitability of this
  41. X * software for any purpose.  It is provided "as is" without express or
  42. X * implied warranty, to the extent permitted by applicable law.
  43. X *
  44. X */
  45. X
  46. X
  47. Xstatic char rcsid[]="$Header: starsunv.c,v 1.8 90/02/19 17:57:03 ccount Exp $";
  48. X
  49. X#include <stdio.h>
  50. X#include <math.h>
  51. X#include <ctype.h>
  52. X#include "star3.h"
  53. X
  54. X#ifndef SYSV
  55. X#include <strings.h>
  56. X#else
  57. X#include <string.h>
  58. X#endif
  59. X
  60. X#include <suntool/sunview.h>
  61. X#include <suntool/canvas.h>
  62. X
  63. Xchar *malloc();
  64. X
  65. X
  66. X
  67. X#ifndef INTERACTIVE_CONTROL
  68. Xchar prog[] = "Starsunv";
  69. X#else
  70. Xextern char prog[];
  71. X#endif
  72. X
  73. X#define BLACK 0
  74. X#define WHITE 1
  75. X#define RED 2
  76. X#define ORANGE 3
  77. X#define YELLOW 4
  78. X#define GREEN 5
  79. X#define CYAN 6
  80. X#define BLUE 7
  81. X#define VIOLET 8
  82. X#define BLUE_WHITE 9
  83. X
  84. X/* Externs */
  85. Xextern int g_argc;
  86. Xextern char **g_argv;
  87. X
  88. Xextern char *title;
  89. X
  90. Xextern mapwindow *mapwin[MAXWINDOWS];
  91. Xextern int numwins;
  92. X
  93. Xextern int cur_function;
  94. Xextern int cur_map_type;
  95. Xextern int cur_map_tag;
  96. Xextern char *cur_tag_field;
  97. X
  98. X
  99. X/* Scale multiplier, minimum,
  100. X   mangitude change, maximum, for thumbnail */
  101. X#define THSMUL 1.2
  102. X#define THSMIN 12.0
  103. X#define THMADJ 2.5
  104. X#define THMMAX 8.0
  105. X
  106. Xmapwindow fullpage = {920, 700, 20, 48,
  107. X                      8.0, 2.0, 2.05, FULLPAGEMAP, 0, "String",
  108. X                      SANSONS, FALSE, FALSE, 0.5, 5.0, 0.0, 0.0, FALSE,};
  109. Xmapwindow mainmap = {920, 480, 20, 268,
  110. X                     8.0, 3.0, 2.05, MAINMAP, 0, "String", 
  111. X                     SANSONS, FALSE, FALSE, 0.5, 5.0, 0.0, 0.0, FALSE,};
  112. Xmapwindow thumbmap = {480, 195, 420, 35, 6.0+THMADJ, 1.0+THMADJ, 2.05+THMADJ,
  113. X                     THUMBNAIL, 0, "String", SANSONS, FALSE, FALSE, 0.5, 5.0,
  114. X                     0.0, 0.0, FALSE,};
  115. X
  116. Xint htick_lim=2;
  117. Xint htext_lim = 80;
  118. Xint htext_xoff = 2;
  119. Xint htext_yoff = 17;
  120. Xint vtick_lim = 2;
  121. Xint vtext_lim = 20;
  122. Xint vtext_xoff = 24;
  123. Xint vtext_yoff = 0;
  124. X
  125. X/* externs for labels */
  126. Xint x_nameoffset = 10, y_nameoffset = 0;
  127. Xint x_lbloffset = 7, y_lbloffset = 0;
  128. Xint x_magoffset = 7, y_magoffset = -10;
  129. X
  130. X/* externs for legend: variables of positioning are here */
  131. Xint l_til=105;
  132. Xint l_stil=85;
  133. X
  134. Xint l_lmar1=25;
  135. Xint l_lmar2=50;
  136. Xint l_ltext=75;
  137. Xint l_rmar1=150;
  138. Xint l_rmar2=175;
  139. Xint l_rtext=200;
  140. X
  141. Xint l_line1=72;
  142. Xint l_line2=60;
  143. Xint l_line3=47;
  144. Xint l_line4=35;
  145. Xint l_line5=22;
  146. Xint l_line6=10;
  147. X
  148. X/* Point sizes for font calls */
  149. Xint titlesize=18;
  150. Xint subtlsize=12;
  151. Xint namesize=10;
  152. Xint lblsize=10;
  153. Xint magsize=8;
  154. X
  155. X/* Fonts for font calls */
  156. Xint namefnt=TIMESROMAN;
  157. Xint lblfnt=TIMESROMAN;
  158. Xint magfnt=COURIER;
  159. Xint titlefnt=TIMESBOLD;
  160. Xint subtlfnt=TIMESROMAN;
  161. X
  162. X/* Scale multiplier, minimum,
  163. X   mangitude change, maximum, for thumbnail,*/
  164. Xdouble th_smul=THSMUL;
  165. Xdouble th_smin=THSMIN;
  166. Xdouble th_madj=THMADJ;
  167. Xdouble th_mmax=THMMAX;
  168. X
  169. X#define MAX(a,b) ((a)>(b)?(a):(b))
  170. X#define MIN(a,b) ((a)<(b)?(a):(b))
  171. X
  172. X
  173. X/* Font names */
  174. Xstatic char *default_font_name = "/usr/lib/fonts/fixedwidthfonts/screen.r.12";
  175. Xstatic char *greek_font_name = "/usr/lib/fonts/fixedwidthfonts/apl.r.10";
  176. Xstatic char *timesroman_font_name = "/usr/lib/fonts/fixedwidthfonts/serif.r.10";
  177. Xstatic char *timesbold_font_name = "/usr/lib/fonts/fixedwidthfonts/serif.r.10";
  178. Xstatic char *timesital_font_name = "/usr/lib/fonts/fixedwidthfonts/serif.r.10";
  179. Xstatic char *timesboldital_font_name = "/usr/lib/fonts/fixedwidthfonts/serif.r.10";
  180. Xstatic char *helv_font_name = "/usr/lib/fonts/fixedwidthfonts/gacha.r.8";
  181. Xstatic char *helvbold_font_name = "/usr/lib/fonts/fixedwidthfonts/gacha.b.8";
  182. Xstatic char *helvital_font_name = "/usr/lib/fonts/fixedwidthfonts/gacha.r.8";
  183. Xstatic char *helvboldital_font_name = "/usr/lib/fonts/fixedwidthfonts/gachs.b.8";
  184. Xstatic char *courier_font_name = "/usr/lib/fonts/fixedwidthfonts/cour.r.10";
  185. Xstatic char *courital_font_name = "/usr/lib/fonts/fixedwidthfonts/cour.r.10";
  186. Xstatic char *courbold_font_name = "/usr/lib/fonts/fixedwidthfonts/cour.b.10";
  187. Xstatic char *couritalbold_font_name = "/usr/lib/fonts/fixedwidthfonts/cour.b.10";
  188. X
  189. X
  190. X/* Sunview things */
  191. XFrame frame;
  192. XCanvas canvas;
  193. XPixwin *pw;
  194. XPr_brush pr_br = { 0 };
  195. XPr_texture dash_tex;
  196. Xshort dash_patts[][3] = {
  197. X  {1, 1, 0},
  198. X  {2, 2, 0},
  199. X  {3, 3, 0},
  200. X  {4, 4, 0},
  201. X  {5, 5, 0},
  202. X  {6, 6, 0},
  203. X  {7, 7, 0},
  204. X  {8, 8, 0},
  205. X  {9, 9, 0},
  206. X  {10, 10, 0}
  207. X};
  208. Xstatic Pixfont *greek_pfont;
  209. X
  210. Xint is_color = TRUE;        /* Is it color? */
  211. Xint is_super_color = TRUE;    /* Is it many color? */
  212. Xint ncolors, star_colors;
  213. Xunsigned int width, height;
  214. Xint draw_color = 1;
  215. X
  216. X/* Device control argument */
  217. XD_control_arg(s)
  218. Xchar *s;
  219. X{
  220. X  int i = 0;
  221. X  int c;
  222. X
  223. X  while (c = s[i++]) switch (c) {
  224. X  case 'm': /* monochrome display */
  225. X    is_color = FALSE;
  226. X  default:
  227. X    break;
  228. X  }
  229. X}
  230. X
  231. X
  232. X#ifndef INTERACTIVE_CONTROL
  233. X
  234. Xvoid
  235. Xmouse_event_proc(window, event, arg)
  236. XWindow window;
  237. XEvent *event;
  238. Xcaddr_t arg;
  239. X{
  240. X  int x, y;
  241. X  int i;
  242. X  double lat, lon, tlat, tlon;
  243. X  char outstr[81];
  244. X  int ra_h, ra_m, ra_s;
  245. X  int de_d, de_m, de_s;
  246. X  char dsign;
  247. X
  248. X  if (event_is_up(event))
  249. X    return;
  250. X
  251. X  x = event_x(event);
  252. X  y = event_y(event);
  253. X
  254. X  switch(event_action(event)) {
  255. X  case MS_LEFT:
  256. X  case MS_RIGHT:
  257. X    if ((i = invxform(x, height - y, &lat, &lon)) >= 0) {
  258. X      if (lon < 0.0) lon += 360.0;
  259. X      tlon = lon / 15.0;
  260. X
  261. X      ra_h = tlon;
  262. X      ra_m = (tlon - ra_h) * 60 + (0.5 / 60);
  263. X      ra_s = (((tlon - ra_h) * 60) - ra_m) * 60 + 0.5;
  264. X
  265. X      if (ra_s >= 60) {ra_s -= 60; ra_m++;};
  266. X      if (ra_m >= 60) {ra_m -= 60; ra_h++;};
  267. X
  268. X
  269. X      if (lat < 0.0) {
  270. X    tlat = -lat;
  271. X    dsign = '-';
  272. X      } else {
  273. X    tlat = lat;
  274. X    dsign = '+';
  275. X      }
  276. X
  277. X      de_d = tlat;
  278. X      de_m = (tlat - de_d) * 60 + (0.5 / 60);
  279. X      de_s = (((tlat - de_d) * 60) - de_m) * 60 + 0.5;
  280. X
  281. X      if (de_s >= 60) {de_s -= 60; de_m++;};
  282. X      if (de_m >= 60) {de_m -= 60; de_d++;};
  283. X
  284. X
  285. X      sprintf(outstr, "RA: %2dh%2dm%2ds   dec: %c%2dd%2dm%2ds",
  286. X          ra_h, ra_m, ra_s, dsign, de_d, de_m, de_s);
  287. X      D_comment(outstr);
  288. X      if (event_action(event) == MS_RIGHT)
  289. X    dblookup(i, lat, lon, 10);
  290. X    }
  291. X    break;
  292. X  default:
  293. X    break;
  294. X  };
  295. X}
  296. X
  297. X
  298. X/* Open the device */
  299. XD_open()
  300. X{
  301. X  unsigned int map_width;
  302. X  double legend_spacing;
  303. X
  304. X  width = 650; height = 768;
  305. X
  306. X  /* Create frame and canvas */
  307. X  frame = window_create(NULL, FRAME, FRAME_LABEL, "Hello there",
  308. X            WIN_HEIGHT, height + 30,
  309. X            WIN_WIDTH, width + 20,
  310. X            0);
  311. X  if (!(frame))
  312. X    return FALSE;
  313. X
  314. X  canvas = window_create(frame, CANVAS,
  315. X             WIN_HEIGHT, height,
  316. X             WIN_WIDTH, width,
  317. X             WIN_EVENT_PROC, mouse_event_proc,
  318. X             0);
  319. X
  320. X
  321. X  window_set(canvas,
  322. X         CANVAS_AUTO_SHRINK, FALSE,
  323. X         CANVAS_AUTO_EXPAND, FALSE,
  324. X         0);
  325. X
  326. X  /* get the canvas pixwin to draw into */
  327. X  pw = canvas_pixwin(canvas);
  328. X
  329. X  is_color &= (pw->pw_pixrect->pr_depth >= 4);
  330. X  is_super_color = is_color & (pw->pw_pixrect->pr_depth >= 6);
  331. X  ncolors = (is_color ? 12 : 2);
  332. X  star_colors = (is_super_color ? 65: 0);
  333. X
  334. X  D_setcolors();
  335. X
  336. X  map_width = width - 75;
  337. X
  338. X  fullpage.width = map_width;
  339. X  fullpage.height = height - 50;
  340. X  fullpage.x_offset = 25;
  341. X  fullpage.y_offset = 25;
  342. X
  343. X  mainmap.width = map_width;
  344. X  mainmap.height = ((height -25 - 25 - 25)*3)/4;
  345. X  mainmap.x_offset = 25;
  346. X  mainmap.y_offset = 25 + (height -25 - 25 - 25)/4 + 25;
  347. X
  348. X  thumbmap.width = map_width/2;
  349. X  thumbmap.height = (height -25 - 25 - 25)/4;
  350. X  thumbmap.x_offset = 25 + map_width/2;
  351. X  thumbmap.y_offset = 25;
  352. X
  353. X  /* Need to adjust label here */
  354. X  /* Want top of l_til to be at top of thumbmap */
  355. X  l_til = thumbmap.height + thumbmap.y_offset - titlesize;
  356. X  /* Space text in legends to fill space.  Leave 10 on bottom.
  357. X     Text totals 6*namesize+subtlsize. */
  358. X
  359. X  legend_spacing = (l_til - 10 - 6*namesize - subtlsize)/7;
  360. X  if (legend_spacing < 2) legend_spacing = 2;
  361. X
  362. X  l_stil = l_til - subtlsize - legend_spacing;
  363. X  l_line1 = l_stil - namesize - legend_spacing;
  364. X  l_line2 = l_line1 - namesize - legend_spacing;
  365. X  l_line3 = l_line2 - namesize - legend_spacing;
  366. X  l_line4 = l_line3 - namesize - legend_spacing;
  367. X  l_line5 = l_line4 - namesize - legend_spacing;
  368. X  l_line6 = l_line5 - namesize - legend_spacing;
  369. X
  370. X  greek_pfont = pf_open(greek_font_name);
  371. X
  372. X  
  373. X  /* Clear to black */
  374. X  {
  375. X    int i;
  376. X    /* I don't underatanmd pw_polygon_2, so won't use it */
  377. X/*
  378. X    for (i = 0; i < width; i++) {
  379. X      pw_vector(pw, i, 0, i, 30, PIX_SRC, 0);
  380. X      pw_vector(pw, i, 30, i, 60, PIX_SRC, 1);
  381. X      pw_vector(pw, i, 60, i, 90, PIX_SRC, 2);
  382. X      pw_vector(pw, i, 90, i, 120, PIX_SRC, 3);
  383. X      pw_vector(pw, i, 120, i, 150, PIX_SRC, 4);
  384. X      pw_vector(pw, i, 150, i, 180, PIX_SRC, 5);
  385. X      pw_vector(pw, i, 180, i, 210, PIX_SRC, 6);
  386. X      pw_vector(pw, i, 210, i, 240, PIX_SRC, 7);
  387. X      pw_vector(pw, i, 240, i, 270, PIX_SRC, 8);
  388. X      pw_vector(pw, i, 270, i, 300, PIX_SRC, 9);
  389. X      pw_vector(pw, i, 300, i, 330, PIX_SRC, 10);
  390. X      pw_vector(pw, i, 330, i, 360, PIX_SRC, 11);
  391. X      pw_vector(pw, i, 360, i, 390, PIX_SRC, 12);
  392. X      pw_vector(pw, i, 390, i, 420, PIX_SRC, 13);
  393. X      pw_vector(pw, i, 420, i, 450, PIX_SRC, 14);
  394. X      pw_vector(pw, i, 450, i, 480, PIX_SRC, 15);
  395. X    }
  396. X*/
  397. X  }
  398. X
  399. X  return TRUE;                /* open successful */
  400. X}
  401. X
  402. X/* Close the device */
  403. XD_close()
  404. X{
  405. X  window_main_loop(frame);
  406. X  exit(1);   
  407. X}
  408. X
  409. X#endif /* not INTERACTIVE_CONTROL */
  410. X
  411. X
  412. X/* Readstar globals */
  413. Xextern double obj_lat, obj_lon, obj_mag;
  414. Xextern char obj_type[3], obj_color[3], obj_label[3];
  415. Xextern char obj_constell[3], obj_name[];
  416. Xextern char *obj_commnt, fileline[];
  417. X
  418. X/* needed by readstar */
  419. Xint (*readfile)();
  420. Xextern char *cur_file_name;
  421. X
  422. Xdblookup(winnum, lat, lon, dpix)
  423. X     int winnum;
  424. X     double lat, lon;
  425. X     int dpix;
  426. X{
  427. X  int i;
  428. X  double delta;
  429. X  double f_east, f_north, f_west, f_south;
  430. X  FILE *file1, *file2;
  431. X  char ibuf[2020], fname[1030], ftypestr[32];
  432. X  int n;
  433. X  int ftype;
  434. X
  435. X  D_comment("Looking for object");
  436. X  
  437. X  delta = mapwin[winnum]->c_scale * dpix;
  438. X
  439. X  for (i = 0; i < mapwin[winnum]->numfiles; i++) {
  440. X    if ((file1 = fopen(mapwin[winnum]->file[i].name, "r")) == NULL) continue;
  441. X
  442. X    cur_file_name = mapwin[winnum]->file[i].name;
  443. X    ftype = mapwin[winnum]->file[i].type;
  444. X    if (mapwin[winnum]->file[i].type == INDEXTYPE) {
  445. X      /* read each line of index file, parse data on the files indexed:
  446. X     region_included file_name
  447. X         use an indexed file if the point is in the region */
  448. X
  449. X      while (!feof(file1)) {
  450. X    fgets(ibuf, 2000, file1);
  451. X    n = sscanf(ibuf, "%lf %lf %lf %lf %1000s %30s\n", &f_east, &f_north,
  452. X           &f_west, &f_south, fname, ftypestr);
  453. X    if ((n != 6) || feof(file1)) continue;
  454. X
  455. X    f_east *= 15.0;
  456. X    f_west *= 15.0;
  457. X
  458. X    if (westof(lon, f_east) && eastof(lon, f_west)
  459. X        && (lat >= f_south) && (lat <= f_north)) {
  460. X      if ((file2 = fopen(fname, "r")) == NULL) {
  461. X        fprintf(stderr, "%s: error, couldn't open '%s' for reading.\n",
  462. X            prog, fname);
  463. X      } else {
  464. X        cur_file_name = fname;
  465. X
  466. X        ftype = tr_fty(ftypestr);
  467. X
  468. X        if (ftype == INDEXTYPE)  {
  469. X          fprintf(stderr,
  470. X  "%s: error, can't use type INDEXTYPE file '%s' from another index file.\n",
  471. X              prog, fname);
  472. X        } else {
  473. X          do_look(file2, ftype, lat, lon, delta);
  474. X        }
  475. X        fclose(file2);
  476. X        cur_file_name = "";
  477. X      }
  478. X    }
  479. X      }
  480. X    } else {
  481. X      do_look(file1, ftype, lat, lon, delta);
  482. X    }
  483. X
  484. X    fclose(file1);
  485. X  };
  486. X
  487. X  D_comment("Done search");
  488. X}
  489. X
  490. Xdo_look(file, ftype, lat, lon, delta)
  491. XFILE *file;
  492. Xint ftype;
  493. Xdouble lat, lon, delta;
  494. X{
  495. X  double dlat, dlon;
  496. X  double tlat, tlon;
  497. X  int ra_h, ra_m, ra_s;
  498. X  int de_d, de_m, de_s;
  499. X  char dsign;
  500. X
  501. X  char outstr[81];
  502. X
  503. X
  504. X  while (!(*readfile)(file, ftype)) {
  505. X    dlat = fabs(obj_lat - lat);
  506. X    dlon = fabs(obj_lon - lon);
  507. X    if ((dlat <= delta) && (dlon <= delta)) {
  508. X      tlon = obj_lon/15.0;
  509. X      ra_h = tlon;
  510. X      ra_m = (tlon - ra_h) * 60 + (0.5 / 60);
  511. X      ra_s = (((tlon - ra_h) * 60) - ra_m) * 60 + 0.5;
  512. X
  513. X      if (ra_s >= 60) {ra_s -= 60; ra_m++;};
  514. X      if (ra_m >= 60) {ra_m -= 60; ra_h++;};
  515. X
  516. X
  517. X      if (obj_lat < 0.0) {
  518. X    tlat = -obj_lat;
  519. X    dsign = '-';
  520. X      } else {
  521. X    tlat = obj_lat;
  522. X    dsign = '+';
  523. X      }
  524. X
  525. X      de_d = tlat;
  526. X      de_m = (tlat - de_d) * 60 + (0.5 / 60);
  527. X      de_s = (((tlat - de_d) * 60) - de_m) * 60 + 0.5;
  528. X
  529. X      if (de_s >= 60) {de_s -= 60; de_m++;};
  530. X      if (de_m >= 60) {de_m -= 60; de_d++;};
  531. X
  532. X
  533. X
  534. X      sprintf(outstr,
  535. X      "%2dh%2dm%2ds %c%2dd%2dm%2ds %5.2f %2s %2s %2s %3s %-25.25s %-14.14s",
  536. X          ra_h, ra_m, ra_s, dsign, de_d, de_m, de_s, obj_mag,
  537. X          obj_type,  obj_color, obj_label, obj_constell,
  538. X          obj_name, obj_commnt);
  539. X      D_comment(outstr);
  540. X    }
  541. X  }
  542. X}
  543. X
  544. X
  545. Xstatic int current_x, current_y;
  546. X
  547. X/* Move to (x, y) */
  548. XD_move(x, y)
  549. X     int x, y;
  550. X{
  551. X  current_x = x; current_y = y;
  552. X}
  553. X
  554. X
  555. Xstatic int curr_lsty = -1;
  556. X/* Draw a line of style line_style from the current point to (x, y) */
  557. XD_draw(x, y, line_style)
  558. X     int x, y, line_style;
  559. X{
  560. X  int xline_sty;
  561. X  int dashes = 1;
  562. X  Pr_texture *texture;
  563. X
  564. X  switch (cur_function) {
  565. X  case CHRTOUTLN:
  566. X  case CHRTHTICK:
  567. X  case CHRTVTICK:
  568. X    xline_sty = SOLID;
  569. X    dashes = 1;
  570. X    break;
  571. X  case GRID_RA:
  572. X  case GRID_DEC:
  573. X    xline_sty = DASHED;
  574. X    dashes = 4;
  575. X    break;
  576. X  case ECLIPT:
  577. X    xline_sty = DASHED;
  578. X    dashes = 1;
  579. X    break;
  580. X  case CONSTBOUND:
  581. X    xline_sty = DASHED;
  582. X    dashes = 6;
  583. X    break;
  584. X  case CONSTPATTRN:
  585. X    xline_sty = DASHED;
  586. X    dashes = 8;
  587. X    break;
  588. X  case CONSTNAME:
  589. X  case CHARTFILE:
  590. X  default:
  591. X    switch (line_style) {
  592. X    case SOLID:
  593. X    case VECSOLID:
  594. X      xline_sty = SOLID;
  595. X      dashes = 1;
  596. X      break;
  597. X    case DASHED:
  598. X    case VECDASH:
  599. X      xline_sty = DASHED;
  600. X      dashes = 5;
  601. X      break;
  602. X    case DOTTED:
  603. X    case VECDOT:
  604. X      xline_sty = DASHED;
  605. X      dashes = 1;
  606. X      break;
  607. X    default:
  608. X      xline_sty = SOLID;
  609. X      dashes = 1;
  610. X      break;
  611. X    };
  612. X    break;
  613. X  }
  614. X
  615. X  if (xline_sty == SOLID)  {
  616. X    texture = NULL;
  617. X  } else {
  618. X    texture = &dash_tex;
  619. X
  620. X    texture->pattern = dash_patts[dashes];
  621. X  }
  622. X
  623. X  pw_line(pw, current_x, (int)(height - current_y),
  624. X      x, (int)(height - y), &pr_br, texture,
  625. X      PIX_SRC | PIX_COLOR(draw_color));
  626. X
  627. X
  628. X  curr_lsty = xline_sty;
  629. X
  630. X  current_x = x; current_y = y;
  631. X}
  632. X/* This routine is encouraged to look at the extern cur_funtion
  633. X   and change the line style drawn as desired */
  634. X
  635. X
  636. X/* Move to (x1, y1) then draw a line of style line_style to (x2, y2) */
  637. XD_movedraw(x1, y1, x2, y2, line_style)
  638. X     int x1, y1, x2, y2, line_style;
  639. X{
  640. X  D_move(x1, y1);
  641. X  D_draw(x2, y2, line_style);
  642. X}
  643. X
  644. X
  645. Xstatic struct pr_pos areapts[1000];
  646. Xstatic int nareapts;
  647. X/* Move to (x, y) to begin an area */
  648. XD_areamove(x, y)
  649. X     int x, y;
  650. X{
  651. X  nareapts = 0;
  652. X  areapts[nareapts].x = x;
  653. X  areapts[nareapts].y = height - y;
  654. X  nareapts++;
  655. X}
  656. X
  657. X/* Add a segment to the area border */
  658. XD_areaadd(x, y)
  659. X     int x, y;
  660. X{
  661. X  areapts[nareapts].x = x;
  662. X  areapts[nareapts].y = height - y;
  663. X  nareapts++;
  664. X}
  665. X
  666. X/* Fill the area, after adding the last segment */
  667. XD_areafill(x, y)
  668. X     int x, y;
  669. X{
  670. X  areapts[nareapts].x = x;
  671. X  areapts[nareapts].y = height - y;
  672. X  nareapts++;
  673. X
  674. X  pw_polygon_2(pw, 0, 0, 1, &nareapts, areapts, PIX_SRC|PIX_COLOR(draw_color),
  675. X      NULL, 0, 0);
  676. X
  677. X  nareapts = 0;
  678. X}
  679. X
  680. X/* Set the color to be used for lines and text */
  681. X/* color_str is a 2 char (+ '\0') string
  682. X   containing a specification for a color,
  683. X   e.g. "G2" for the color of a star of spectral class G2, or "r7" for
  684. X   red, level seven.  The interpretation of the color string is left to
  685. X   the device driver */
  686. XD_color(color_str)
  687. X     char *color_str;
  688. X{
  689. X  int colr;
  690. X  int class, subclass;
  691. X  static char *table = "OBAFGKMRNSrgbycpow";
  692. X  static int spectra[10] = {
  693. X    BLUE_WHITE, BLUE, WHITE, WHITE, YELLOW, ORANGE, RED, RED, RED};
  694. X
  695. X  static int super_spectra[][10] = {
  696. X    /*         0   1   2   3   4   5   6   7   8   9   */
  697. X    /* O */ { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 },
  698. X    /* B */ {  0,  1,  2,  3,  3,  4,  4,  4,  5,  6 },
  699. X    /* A */ {  7,  7,  8,  9,  9, 10, 10, 10, 10, 10 },
  700. X    /* F */ { 11, 11, 12, 12, 12, 13, 13, 13, 14, 14 },
  701. X    /* G */ { 15, 15, 15, 15, 15, 16, 16, 16, 16, 16 },
  702. X    /* K */ { 17, 17, 18, 18, 18, 19, 19, 19, 19, 19 },
  703. X    /* M */ { 20, 20, 21, 22, 23, 24, 25, 26, 26, 26 },
  704. X    /* R */ { 27, 27, 27, 28, 28, 28, 28, 28, 29, 30 },
  705. X    /* N */ { 27, 27, 27, 28, 28, 28, 28, 28, 29, 30 },
  706. X    /* S */ { 30, 30, 30, 30, 31, 31, 31, 31, 31, 31 },
  707. X    /* r */ { 33, 33, 33, 34, 34, 34, 35, 35, 35, 36 },
  708. X    /* g */ { 37, 37, 37, 38, 38, 38, 39, 39, 39, 40 },
  709. X    /* b */ { 41, 41, 41, 42, 42, 42, 43, 43, 43, 44 },
  710. X    /* y */ { 45, 45, 45, 46, 46, 46, 47, 47, 47, 48 },
  711. X    /* c */ { 49, 49, 49, 50, 50, 50, 51, 51, 51, 52 },
  712. X    /* p */ { 53, 53, 53, 54, 54, 54, 55, 55, 55, 56 },
  713. X    /* o */ { 57, 57, 57, 58, 58, 58, 59, 59, 59, 60 },
  714. X    /* w */ { 61, 61, 61, 62, 62, 62, 63, 63, 63, 64 }
  715. X      };
  716. X
  717. X  if (!is_color) return;
  718. X
  719. X  class = 0;
  720. X  while (table[class] && (table[class] != color_str[0])) class++;
  721. X
  722. X  if (is_super_color) {
  723. X    subclass = isdigit(color_str[1]) ? color_str[1] - '0' : 0;
  724. X    colr = table[class] ? (10+super_spectra[class][subclass]) : WHITE;
  725. X  } else
  726. X    colr = table[class] ? spectra[class] : WHITE;
  727. X
  728. X  draw_color = colr;
  729. X}
  730. X
  731. X
  732. Xstatic int current_font = -1, current_fsize = -1;
  733. Xstatic Pixfont *curr_pfont;
  734. X
  735. X/* Set the font and font size to be used for text. */
  736. X/* Note order of args */
  737. XD_fontsize(fsize, font)
  738. X     int font, fsize;
  739. X{
  740. X  char *fontname, readname[50];
  741. X
  742. X  switch(cur_function) {
  743. X  case CHRTOUTLN:
  744. X    break;
  745. X  case CHRTHTICK:
  746. X  case CHRTVTICK:
  747. X    font = TIMESBOLD;
  748. X    break;
  749. X  case GRID_RA:
  750. X  case GRID_DEC:
  751. X  case ECLIPT:
  752. X    break;
  753. X  case CONSTBOUND:
  754. X  case CONSTPATTRN:
  755. X    break;
  756. X  case CONSTNAME:
  757. X    font = HELVITAL;
  758. X    break;
  759. X  case CHARTFILE:
  760. X  case CURNTFONT:
  761. X  default:
  762. X    break;
  763. X  }
  764. X
  765. X  if ((font == current_font) && (fsize == current_fsize)) return;
  766. X
  767. X  switch(font)
  768. X    {
  769. X    case TIMESROMAN: fontname = timesroman_font_name; break;
  770. X    case TIMESBOLD: fontname = timesbold_font_name; break;
  771. X    case TIMESITAL: fontname = timesital_font_name; break;
  772. X    case TIMESBOLDITAL: fontname = timesboldital_font_name; break;
  773. X    case HELV: fontname = helv_font_name; break;
  774. X    case HELVBOLD: fontname = helvbold_font_name; break;
  775. X    case HELVITAL: fontname = helvital_font_name; break;
  776. X    case HELVBOLDITAL: fontname = helvboldital_font_name; break;
  777. X    case COURIER: fontname = courier_font_name; break;
  778. X    case COURITAL: fontname = courital_font_name; break;
  779. X    case COURBOLD: fontname = courbold_font_name; break;
  780. X    case COURITALBOLD: fontname = couritalbold_font_name; break;
  781. X    }
  782. X
  783. X  current_font = font;
  784. X  current_fsize = fsize;
  785. X
  786. X  curr_pfont = pf_open(fontname);
  787. X}
  788. X/* This routine is encouraged to look at the extern cur_funtion
  789. X   and change the font used as desired */
  790. X
  791. X
  792. Xstatic char  *intable = " 0123456789abgdezh@iklmnEoprstuOx%w";
  793. Xstatic char *outtable = " 0123456789abgdezhqiklmnxoprstujcyw";
  794. X/* Display text string str at x,y, in current font and font size.
  795. X   if star_lbl is TRUE, string is a star label, use
  796. X      greek characters (if possible) */
  797. XD_text(x, y, s, star_lbl)
  798. X     int x, y;
  799. X     char *s;
  800. X     int star_lbl;
  801. X{
  802. X  char ch;
  803. X  int i, j;
  804. X  int use_greek = FALSE;
  805. X
  806. X  if (star_lbl) {
  807. X    if (isgreek(s[0]) && (isdigit(s[1]) || (s[1] == ' '))) {
  808. X      /* Greek if first character is greek encoded,
  809. X     and the second is space or a digit */
  810. X      use_greek = TRUE;
  811. X#ifdef OLD_GREEK
  812. X      /* Translate yaleformat greek encoding to Symbol font encoding */
  813. X      i = 0;
  814. X      while (ch = s[i])
  815. X    {
  816. X      j = 0;
  817. X      while (intable[j] && (intable[j] != ch)) j++;
  818. X      s[i] = intable[j] ? outtable[j] : s[i];
  819. X      /* If not in translation table, leave it alone */
  820. X      i++;
  821. X    }
  822. X#endif
  823. X    } else { /* Star label, but not greek */
  824. X    /* remove leading spaces */
  825. X    while (*s == ' ') s++;
  826. X    }
  827. X  }
  828. X
  829. X  pw_ttext(pw, x, height - y, PIX_SRC|PIX_COLOR(draw_color),
  830. X      use_greek ? greek_pfont : curr_pfont, s);
  831. X}
  832. X
  833. Xisgreek(c)
  834. Xchar c;
  835. X{
  836. X  char *cp;
  837. X
  838. X#ifdef OLD_GREEK
  839. X  cp = "abgdezh@iklmnEoprstuOx%w";
  840. X#else
  841. X  cp = "abgdezhqiklmnxoprstujcyw";
  842. X#endif
  843. X  while (*cp && (*cp != c)) cp++;
  844. X  return (*cp != '\0'); /* True if letter was in greek string */
  845. X}
  846. X
  847. X
  848. X/* Return input coordinate in device coords where there are pointing devices */
  849. XD_inxy(x, y)
  850. X     int *x, *y;
  851. X{
  852. X}
  853. X
  854. X
  855. X/* Put non-displayed comment in output.  Allowed in postscript, but
  856. X   few other drivers will be able to support this. */ 
  857. X#ifndef INTERACTIVE_CONTROL
  858. XD_comment(str)
  859. X     char *str;
  860. X{
  861. X  fprintf(stdout, "%s\r\n", str);
  862. X}
  863. X#endif
  864. X
  865. X
  866. X
  867. X/**
  868. XHigher level functions
  869. X**/
  870. X
  871. Xdrawlen(x, y, dx, dy, len)
  872. X     int x,y, dx, dy, len;
  873. X{
  874. X  buildlines(x + dx, (int) (height - (y+dy)),
  875. X         x+dx+len, (int)(height - (y+dy)));
  876. X}
  877. X
  878. X
  879. XD_setcolors()
  880. X{
  881. X  static int data[][3] = {
  882. X    {   0,   0,   0 },   /* BLACK */
  883. X    { 255, 255, 255 },   /* WHITE */
  884. X    { 255,   0,   0 },   /* RED */
  885. X    { 255, 100,   0 },   /* ORANGE */
  886. X    { 255, 255,   0 },   /* YELLOW */
  887. X    {   0, 255,   0 },   /* GREEN */
  888. X    {   0, 255, 255 },   /* CYAN */
  889. X    {   0,   0, 255 },   /* BLUE */
  890. X    { 255,   0, 255 },   /* VIOLET */
  891. X    { 130, 130, 255 },   /* BLUE_WHITE */
  892. X  };
  893. X  static double super_data[][3] = {
  894. X    /*  Red             Green          Blue    Name by which type is known */
  895. X    { 0.38937,        0.46526,        0.79493 },    /* B0 */
  896. X    { 0.39501,        0.47146,        0.78847 },    /* B1 */
  897. X    { 0.40103,        0.47792,        0.78151 },    /* B2 */
  898. X    { 0.40640,        0.48355,        0.77526 },    /* B3 */
  899. X    { 0.41341,        0.49071,        0.76701 },    /* B5 */
  900. X    { 0.43251,        0.50914,        0.74412 },    /* B8 */
  901. X    { 0.44342,        0.51897,        0.73079 },    /* B9 */
  902. X    { 0.45181,        0.52618,        0.72042 },    /* A0 */
  903. X    { 0.46931,        0.54026,        0.69847 },    /* A2 */
  904. X    { 0.47958,        0.54792,        0.68541 },    /* A3 */
  905. X    { 0.48538,        0.55205,        0.67797 },    /* A5 */
  906. X    { 0.50879,        0.56731,        0.64752 },    /* F0 */
  907. X    { 0.51732,        0.57231,        0.63627 },    /* F2 */
  908. X    { 0.52348,        0.57573,        0.62810 },    /* F5 */
  909. X    { 0.54076,        0.58447,        0.60496 },    /* F8 */
  910. X    { 0.54853,        0.58799,        0.59446 },    /* G0 */
  911. X    { 0.56951,        0.59623,        0.56584 },    /* G5 */
  912. X    { 0.58992,        0.60244,        0.53765 },    /* K0 */
  913. X    { 0.61098,        0.60693,        0.50828 },    /* K2 */
  914. X    { 0.63856,        0.60977,        0.46950 },    /* K5 */
  915. X    { 0.68698,        0.60595,        0.40110 },    /* M0 */
  916. X    { 0.72528,        0.59434,        0.34744 },    /* M2 */
  917. X    { 0.75182,        0.58144,        0.31097 },    /* M3 */
  918. X    { 0.78033,        0.56272,        0.27282 },    /* M4 */
  919. X    { 0.81066,        0.53676,        0.23394 },    /* M5 */
  920. X    { 0.84247,        0.50195,        0.19570 },    /* M6 */
  921. X    { 0.87512,        0.45667,        0.16004 },    /* M7 */
  922. X    { 0.71033,        0.59983,        0.36829 },    /* N0 */
  923. X    { 0.78625,        0.55816,        0.26507 },    /* N3 */
  924. X    { 0.93792,        0.33011,        0.10649 },    /* N8 */
  925. X    { 0.94897,        0.29906,        0.10012 },    /* N9 */
  926. X    { 0.79832,        0.54811,        0.24950 },    /* S4 */
  927. X    { 0.38241,        0.45743,        0.80282 },    /* O  */
  928. X  };
  929. X  static struct {u_char r, g, b} other_colrs[] = {
  930. X    { 0x80, 0, 0},
  931. X    { 0xc0, 0, 0},
  932. X    { 0xe0, 0, 0},
  933. X    { 0xff, 0, 0},
  934. X    { 0x0, 0x80, 0},
  935. X    { 0x0, 0xc0, 0},
  936. X    { 0x0, 0xe0, 0},
  937. X    { 0x0, 0xff, 0},
  938. X    { 0x0, 0x0, 0x80},
  939. X    { 0x0, 0x0, 0xc0},
  940. X    { 0x0, 0x0, 0xe0},
  941. X    { 0x0, 0x0, 0xff},
  942. X    { 0x80, 0x80, 0x0},
  943. X    { 0xc0, 0xc0, 0x0},
  944. X    { 0xe0, 0xe0, 0x0},
  945. X    { 0xff, 0xff, 0x0},
  946. X    { 0x0, 0x80, 0x80},
  947. X    { 0x0, 0xc0, 0xc0},
  948. X    { 0x0, 0xe0, 0xe0},
  949. X    { 0x0, 0xff, 0xff},
  950. X    { 0x80, 0x0, 0x80},
  951. X    { 0xc0, 0x0, 0xc0},
  952. X    { 0xe0, 0x0, 0xe0},
  953. X    { 0xff, 0x0, 0xff},
  954. X    { 0x80, 0x40, 0x00},
  955. X    { 0xc0, 0x60, 0x00},
  956. X    { 0xe0, 0x70, 0x00},
  957. X    { 0xff, 0x80, 0x00},
  958. X    { 0x80, 0x80, 0x80},
  959. X    { 0xc0, 0xc0, 0xc0},
  960. X    { 0xe0, 0xe0, 0xe0},
  961. X    { 0xff, 0xff, 0xff}
  962. X  };
  963. X  u_char red[255], green[255], blue[255];
  964. X  double max_colr;
  965. X  int i;
  966. X  static int plane_colors[] = { 1, 2, 4, 8, 16, 32, 64, 128, 256};
  967. X
  968. X
  969. X  for (i=0; i< 256; i++) {
  970. X    red[i] = 0;
  971. X    green[i] = 0;
  972. X    blue[i] = 0;
  973. X  };
  974. X
  975. X  for (i=0; i<=9; i++) {
  976. X    red[i] = data[i][0];
  977. X    green[i] = data[i][1];
  978. X    blue[i] = data[i][2];
  979. X  };
  980. X
  981. X  if (is_super_color) {
  982. X    for (i=0; i<=32; i++) {
  983. X      max_colr = super_data[i][0];
  984. X      max_colr = super_data[i][1] > max_colr ? super_data[i][1] : max_colr;
  985. X      max_colr = super_data[i][2] > max_colr ? super_data[i][2] : max_colr;
  986. X      red[i+10] = (int) 255*super_data[i][0] / max_colr;
  987. X      green[i+10] = (int) 255*super_data[i][1] /max_colr;
  988. X      blue[i+10] = (int) 255*super_data[i][2] /max_colr;
  989. X    }
  990. X
  991. X    for (i = 33; i <= 64; i++) {
  992. X      red[i+10] = other_colrs[i-33].r;
  993. X      green[i+10] = other_colrs[i-33].g;
  994. X      blue[i+10] = other_colrs[i-33].b;
  995. X    };
  996. X  }
  997. X
  998. X  i = plane_colors[pw->pw_pixrect->pr_depth];
  999. X  red[i-1] = blue[i-1] = green[i-1] = 255;
  1000. X
  1001. X  pw_setcmsname(pw, "starcolors");
  1002. X  pw_putcolormap(pw, 0, plane_colors[pw->pw_pixrect->pr_depth],
  1003. X         red, green, blue);
  1004. X}
  1005. X
  1006. X
  1007. X
  1008. X#ifndef INTERACTIVE_CONTROL
  1009. Xbuildlines(x1, y1, x2, y2)
  1010. X     int x1, y1, x2, y2;
  1011. X{
  1012. X  pw_line(pw, x1, y1, x2, y2, &pr_br, NULL,
  1013. X      PIX_SRC | PIX_COLOR(draw_color));
  1014. X}
  1015. X
  1016. X
  1017. X#endif /* not INTERACTIVE_CONTROL */
  1018. X
  1019. X
  1020. END_OF_FILE
  1021. if test 25159 -ne `wc -c <'starchart/starsunv.c'`; then
  1022.     echo shar: \"'starchart/starsunv.c'\" unpacked with wrong size!
  1023. fi
  1024. # end of 'starchart/starsunv.c'
  1025. fi
  1026. echo shar: End of archive 14 \(of 32\).
  1027. cp /dev/null ark14isdone
  1028. MISSING=""
  1029. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ; do
  1030.     if test ! -f ark${I}isdone ; then
  1031.     MISSING="${MISSING} ${I}"
  1032.     fi
  1033. done
  1034. if test "${MISSING}" = "" ; then
  1035.     echo You have unpacked all 32 archives.
  1036.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1037. else
  1038.     echo You still need to unpack the following archives:
  1039.     echo "        " ${MISSING}
  1040. fi
  1041. ##  End of shell archive.
  1042. exit 0
  1043.  
  1044.